package com.eastfair.venueservice.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.eastfair.boot.request.PageParams;
import com.eastfair.boot.service.SuperService;
import com.eastfair.home.dto.ReportServiceAuditDTO;
import com.eastfair.venueservice.dto.ServiceBookingDTO;
import com.eastfair.venueservice.dto.ServiceBookingQuery;
import com.eastfair.venueservice.dto.ServiceItemDTO;
import com.eastfair.venueservice.dto.ServiceOrderDTO;
import com.eastfair.venueservice.entity.ServiceBooking;
import com.eastfair.venueservice.entity.ServiceOrder;
import com.eastfair.venueservice.enumeration.ServiceBookingWorkOrderStatusEnum;
import com.eastfair.venueservice.vo.ReportVenueSpaceNumVO;
import com.eastfair.venueservice.vo.ServiceBookingSimpleVO;
import com.eastfair.venueservice.vo.ServiceBookingStatisticsVO;
import com.eastfair.venueservice.vo.ServiceBookingVO;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 业务接口
 * 服务预订项
 * </p>
 *
 * @author linan
 * @date 2022-08-05
 */
public interface ServiceBookingService extends SuperService<ServiceBooking> {

    /**
     * 查询展位上预定的服务列表.
     *
     * @param serviceBookingDTO the service booking dto
     * @return the list
     */
    List<ServiceBookingVO> listServiceBookingBySiteName(ServiceBookingDTO serviceBookingDTO);

    /**
     * 更新未提交审核的服务预订
     * @param serviceItemDTO
     */
    void updateByItem(ServiceItemDTO serviceItemDTO);

    /**
     * 添加服务预订
     * @param serviceBookingDTO serviceBookingDTO
     * @return Boolean
     */
    Boolean addServiceBooking(List<ServiceBookingDTO> serviceBookingDTO);

    /**
     * 保存服务预订
     * @param serviceBookingDTO serviceBookingDTO
     * @return Boolean
     */
    Boolean saveServiceBooking(List<ServiceBookingDTO> serviceBookingDTO);

    /**
     * 服务预订列表
     * @param serviceBookingQuery serviceBookingQuery
     * @return List<ServiceBookingVO>
     */
    List<ServiceBookingVO> queryServiceBookingList(ServiceBookingQuery serviceBookingQuery);

    /**
     * 回填预订服务的审核接口
     * @param serviceBookingDTO serviceBookingDTO
     * @return Boolean
     */
    Boolean updateServiceBookingAuditResult(List<ServiceBookingDTO> serviceBookingDTO);

    /**
     * 报馆提交服务预订
     * @param reportSpaceId reportSpaceId
     * @param reportSpaceAuditId
     * @return Boolean
     */
    List<ReportServiceAuditDTO> submitServiceBookingWhenReport(Long reportSpaceId, Long reportSpaceAuditId);

    /**
     * 报馆取消服务预订
     * @param reportSpaceId reportSpaceId
     * @return Boolean
     */
    Boolean cancelBookingOfReportSpace(Long reportSpaceId);

    /**
     * 添加服务预订（报馆后预订的服务）
     * @param serviceBookingDTO serviceBookingDTO
     * @return Boolean
     */
    Boolean addServiceBookingAfterReport(List<ServiceBookingDTO> serviceBookingDTO);

    /**
     * 主场一键报馆的全部服务
     * @param serviceBookingQuery
     * @return
     */
    Page<ServiceBookingVO> queryServiceBookingOfHome(PageParams<ServiceBookingQuery> serviceBookingQuery);

    /**
     * 报馆服务列表
     * @param serviceBookingQuery
     * @return
     */
    Page<ServiceBookingVO> queryReportSpaceService(PageParams<ServiceBookingQuery> serviceBookingQuery);

    /**
     * 服务预订管理列表
     * @param serviceBookingQuery
     * @return
     */
    Page<ServiceBookingVO> queryServiceBookingManage(PageParams<ServiceBookingQuery> serviceBookingQuery);

    /**
     * 主场一键报馆服务
     * @param serviceBookingDTO
     * @return
     */
    Boolean submitServiceBookingToVenue(List<ServiceBookingDTO> serviceBookingDTO);

    Boolean submitServiceBookingToVenueOfImport(List<ServiceBookingDTO> serviceBookingDTO);

    /**
     * 查询报馆服务数量
     * @param reportVenueSpaceNumbers
     * @return
     */
    Map<String,Integer> queryBookingServiceNum(List<String> reportVenueSpaceNumbers);

    /**
     * 添加服务预订(主运)
     * @param serviceBookingDTO
     * @return
     */
    Boolean addServiceBookingOfOrder(List<ServiceBookingDTO> serviceBookingDTO);

    /**
     * 服务预订列表（主运）
     * @param serviceBookingQuery serviceBookingQuery
     * @return List<ServiceBookingVO>
     */
    List<ServiceBookingVO> queryServiceBookingListOfOrder(ServiceBookingQuery serviceBookingQuery);

    /**
     * 修改订单下服务提交状态
     *
     * @param serviceOrder
     * @param serviceBookingDTO serviceBookingDTO
     * @return Boolean
     */
    Boolean updateBookingServiceOrderStatus(ServiceOrder serviceOrder, ServiceBookingDTO serviceBookingDTO);

    /**
     * 通过订单编号查询服务
     * @param orderNumber
     * @return
     */
    List<ServiceBookingVO> queryServiceBookingListByOrderNumber(List<String> orderNumber);

    /**
     * Gets service booking map by order number.
     *
     * @param orderNumberList the order number list
     * @return the service booking map by order number
     */
    Map<String, List<ServiceBookingVO>> getServiceBookingMapByOrderNumber(List<String> orderNumberList);

    /**
     * 更新报馆服务的派工状态
     * @param workOrderNo
     * @param hasReceive
     * @return
     */
    Boolean updateWorkOrderStatus(String workOrderNo, ServiceBookingWorkOrderStatusEnum hasReceive);

    /**
     * 统计展厅报馆服务数量
     * @param serviceBookingQuery
     * @return
     */
    List<ServiceBookingVO> queryReportServiceCount(ServiceBookingQuery serviceBookingQuery);

    /**
     * 通过报馆号查询报馆服务
     * @param reportSpaceNumber
     * @param isManageOrNot
     * @return
     */
    List<ServiceBooking> getByReportSpaceNumber(Long reportSpaceNumber, int isManageOrNot);

    /**
     * 更新订单号
     * @param serviceBookingList
     * @param orderNumber
     */
    void updateOrderNumber(List<ServiceBooking> serviceBookingList, String orderNumber);

    /**
     * 更新预定服务的报馆核定状态.
     *
     * @param list the list
     * @return the boolean
     */
    boolean updateReportCheckStatus(List<ServiceBookingDTO> list);

    /**
     * 通过展会查询资金情况
     * @param exhibitionManageId
     * @return
     */
    List<ServiceBookingSimpleVO> queryExhibitionFinance(Long exhibitionManageId);

    /**
     * 报馆展位数量
     * @param exhibitionManageId
     * @return
     */
    List<ReportVenueSpaceNumVO> queryReportSpaceNum(Long exhibitionManageId);

    /**
     * 服务库存预警
     * @return
     */
    List<ServiceBookingSimpleVO> queryWarningRanking();

    /**
     * 订单编号查询预定服务项.
     *
     * @param orderNumber the order number
     * @return the list
     */
    List<ServiceBooking> queryByOrderNumber(String orderNumber);

    /**
     * 取消服务预定项
     * @param id
     * @return
     */
    Boolean cancelSettlementServiceItem(Long id);

    /**
     * 导出展位预定的服务列表.
     *
     * @param serviceBookingDTO   the service booking dto
     * @param httpServletResponse the http servlet response
     * @throws IOException the io exception
     */
    void exportServiceBookingBySiteName(ServiceBookingDTO serviceBookingDTO, HttpServletResponse httpServletResponse) throws IOException;

    /**
     * 报馆核定导入.
     *
     * @param file the file
     * @return the list
     * @throws IOException the io exception
     */
    List<ServiceBookingDTO> importForReportCheck(MultipartFile file) throws IOException;

    /**
     * 查询所有预定的各项服务总金额
     * @param ids
     * @param exhibitionManageId
     * @return
     */
    List<ServiceBookingVO> queryServiceItemAmount(List<Long> ids, Long exhibitionManageId);

    /**
     * 主场一键报馆发送站内信.
     *
     * @param exhibitionManageId the exhibition manage id
     * @param homeId             the home id
     * @return the boolean
     */
    boolean sendVenueReportInnerMsg(Long exhibitionManageId, Long homeId);

    /**
     * 异步主场一键报馆发送站内信
     *
     * @param exhibitionManageId the exhibition manage id
     * @param homeId             the home id
     */
    void asyncSendVenueReportInnerMsg(Long exhibitionManageId, Long homeId);

    /**
     * 统计服务预定排行.
     *
     * @param exhibitionManageId the exhibition manage id
     * @param homeId             the home id
     * @param topN               the top n
     * @return the list
     */
    List<Map<String, Object>> countHomeServiceBookingNum(Long exhibitionManageId, Long homeId, Integer topN);

    /**
     * 统计服务已销售排行.
     *
     * @param exhibitionManageId the exhibition manage id
     * @param homeId             the home id
     * @param topN               the top n
     * @return the list
     */
    List<Map<String, Object>> countHomeHasPayServiceBookingNum(Long exhibitionManageId, Long homeId, Integer topN);

    /**
     * 统计展会报馆进度.
     *
     * @param serviceBookingQuery the service booking query
     * @return the list
     */
    List<ServiceBookingVO> countReportServiceProcess(ServiceBookingQuery serviceBookingQuery);

    /**
     * 主场服务派工
     * @param serviceBookingDTO serviceBookingDTO
     * @return Boolean
     */
    Boolean submitServiceBookingToDispatch(List<ServiceBookingDTO> serviceBookingDTO);

    /**
     * 更新库存
     * @param serviceOrderDTO
     * @return
     */
    Boolean updateServiceInventory(ServiceOrderDTO serviceOrderDTO);

    /**
     * 主办已预定的服务统计
     * @param serviceBookingQuery serviceBookingQuery
     * @return ServiceBookingStatisticsVO
     */
    ServiceBookingStatisticsVO querySponsorServiceBookingStat(ServiceBookingQuery serviceBookingQuery);
}
